<?php

class NewsController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
        $this->_helper->cache(array('index'), array('mee'));
    }

    public function indexAction()
    {
        // action body
        $modelPage = new Ms_Model_Page(); //实例化模型对象
//        $where = array('star'=>4,'top'=>1); // 定义查询条件
        $where = array('type'=>'news'); // 定义查询条件
        $newsStar = $modelPage->getPage($where); //使用模型的getPage方法获取文章
        $this->view->newsStar = $newsStar; // 输出到view视图
        
        // 新闻文章列表
//        $where_list = array('star'=>4, 'top'=>0);
        $order = 'updatetime DESC';
        $limit = 5;
        $newsList = $modelPage->getPages($where, $order, $limit);
        $paginator = new Zend_Paginator($newsList);
        $paginator->setItemCountPerPage('5');
        // 获得当前显示的页码
        $page = $this->_request->getParam('page');
        $paginator->setCurrentPageNumber($page);
        // 渲染到视图
        $this->view->newsList = $paginator;
    }

}

